package org.firebug.spring.boot.exception.controller;

import lombok.Data;
import org.firebug.common.core.api.Response;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping(value = "/user")
public class UserController {
    @RequestMapping(value = "/{id}", method = RequestMethod.GET, params = {"version=1"})
    public Response<User> query(@PathVariable("id") Integer id) {
        return Response.ok(new User());
    }

//    @RequestMapping(value = "/save", method = RequestMethod.POST)
//    public ResponseEntity<User> save(@Validated @RequestBody User user) {
//        return ResponseEntity.status(HttpStatus.OK).body(user);
//    }

    @Data
    static class User {
        @NotNull(message = "id required")
        private Integer id = 1;

        @NotBlank(message = "name required")
        private String name = "felix";
    }
}
